﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace PuzzleDiamonds
{
    public abstract class SceneObject
    {
        protected TranslateTransform m_xForm;
        protected Point m_vPosition;
        protected Point m_vDirection;
        protected double m_dblSpeed;

        public Point Position
        {
            get { return new Point(m_xForm.X, m_xForm.Y); }
            set
            {
                m_vPosition = value;
                m_xForm.X = m_vPosition.X;
                m_xForm.Y = m_vPosition.Y;

            }
        }

        public Point Direction
        {
            get { return m_vDirection; }
            set { m_vDirection = value; }
        }

        public double Speed
        {
            get { return m_dblSpeed; }
            set { m_dblSpeed = value; }
        }

        public SceneObject(Point pPosition, Point pDirection, double pSpeed)
        {
            m_xForm = new TranslateTransform();
            m_xForm.X = pPosition.X;
            m_xForm.Y = pPosition.Y;

            m_vPosition = new Point(pPosition.X, pPosition.Y);

            m_dblSpeed = pSpeed;
            m_vDirection = pDirection;            
        }

        public virtual void Update(double pTick)
        {
            m_xForm.X += m_dblSpeed * m_vDirection.X;
            m_xForm.Y += m_dblSpeed * m_vDirection.Y;

            m_vPosition.X = m_xForm.X;
            m_vPosition.Y = m_xForm.Y;
        }

        public abstract Visual GetVisualObject();
    }
}
